﻿using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using HumanManagement.BusinessObjects;
using HumanManagement.DataAccess;

namespace HumanManagement.BusinessLogic
{
	public class BranchBL
	{

		#region ***** Init Methods ***** 
		BranchDA objBranchDA;
		public BranchBL()
		{
			objBranchDA = new BranchDA();
		}
		#endregion

		#region ***** Get Methods ***** 
		/// <summary>
		/// Get Branch by id
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns>Branch</returns>
		public Branch GetByID(int id)
		{
			return objBranchDA.GetByID(id);
		}

		/// <summary>
		/// Get all of Branch
		/// </summary>
		/// <returns>List<<Branch>></returns>
		public List<Branch> GetList()
		{
			string cacheName = "lstBranch";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objBranchDA.GetList(), "Branch");
			}
			return (List<Branch>) ServerCache.Get(cacheName);
		}

		/// <summary>
		/// Get DataSet of Branch
		/// </summary>
		/// <returns>DataSet</returns>
		public DataSet GetDataSet()
		{
			string cacheName = "dsBranch";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objBranchDA.GetDataSet(), "Branch");
			}
			return (DataSet) ServerCache.Get(cacheName);
		}


		/// <summary>
		/// Get all of Branch paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>List<<Branch>></returns>
		public List<Branch> GetListPaged(int recperpage, int pageindex)
		{
			return objBranchDA.GetListPaged(recperpage, pageindex);
		}

		/// <summary>
		/// Get DataSet of Branch paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>DataSet</returns>
		public DataSet GetDataSetPaged(int recperpage, int pageindex)
		{
			return objBranchDA.GetDataSetPaged(recperpage, pageindex);
		}





		#endregion

		#region ***** Add Update Delete Methods ***** 
		/// <summary>
		/// Add a new Branch within Branch database table
		/// </summary>
		/// <param name="obj_branch">Branch</param>
		/// <returns>key of table</returns>
		public int Add(Branch obj_branch)
		{
			ServerCache.Remove("Branch", true);
			return objBranchDA.Add(obj_branch);
		}

		/// <summary>
		/// updates the specified Branch
		/// </summary>
		/// <param name="obj_branch">Branch</param>
		/// <returns></returns>
		public void Update(Branch obj_branch)
		{
			ServerCache.Remove("Branch", true);
			objBranchDA.Update(obj_branch);
		}

		/// <summary>
		/// Delete the specified Branch
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns></returns>
		public void Delete(int id)
		{
			ServerCache.Remove("Branch", true);
			objBranchDA.Delete(id);
		}
		#endregion
	}
}
